import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class ApiResponseDto<T = any> {
    @ApiProperty({
        description: 'Operation success status',
        example: true
    })
    success: boolean;

    @ApiProperty({
        description: 'Response data',
        example: {}
    })
    data: T;

    @ApiPropertyOptional({
        description: 'Optional message',
        example: 'Operation completed successfully',
        required: false
    })
    message?: string;

    constructor(success: boolean, data: T, message?: string) {
        this.success = success;
        this.data = data;
        this.message = message;
    }

    static success<T>(data: T, message?: string): ApiResponseDto<T> {
        return new ApiResponseDto(true, data, message);
    }

    static error<T>(data: T, message?: string): ApiResponseDto<T> {
        return new ApiResponseDto(false, data, message);
    }
}
